package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiEquipment;
import com.ruoyi.system.service.ILuntaiEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮胎器材Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/equipment")
public class LuntaiEquipmentController extends BaseController
{
    @Autowired
    private ILuntaiEquipmentService luntaiEquipmentService;

    /**
     * 查询轮胎器材列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(LuntaiEquipment luntaiEquipment)
    {
        startPage();
        List<LuntaiEquipment> list = luntaiEquipmentService.selectLuntaiEquipmentList(luntaiEquipment);
        return getDataTable(list);
    }

    /**
     * 查询轮胎器材列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:list')")
    @GetMapping("/list2")
    public AjaxResult list2(LuntaiEquipment luntaiEquipment)
    {
        List<LuntaiEquipment> list = luntaiEquipmentService.selectLuntaiEquipmentList(luntaiEquipment);
        return AjaxResult.success(list);
    }

    /**
     * 导出轮胎器材列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:export')")
    @Log(title = "轮胎器材", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiEquipment luntaiEquipment)
    {
        List<LuntaiEquipment> list = luntaiEquipmentService.selectLuntaiEquipmentList(luntaiEquipment);
        ExcelUtil<LuntaiEquipment> util = new ExcelUtil<LuntaiEquipment>(LuntaiEquipment.class);
        util.exportExcel(response, list, "轮胎器材数据");
    }

    /**
     * 获取轮胎器材详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiEquipmentService.selectLuntaiEquipmentById(id));
    }

    /**
     * 新增轮胎器材
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:add')")
    @Log(title = "轮胎器材", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiEquipment luntaiEquipment)
    {
        return toAjax(luntaiEquipmentService.insertLuntaiEquipment(luntaiEquipment));
    }

    /**
     * 修改轮胎器材
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:edit')")
    @Log(title = "轮胎器材", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiEquipment luntaiEquipment)
    {
        return toAjax(luntaiEquipmentService.updateLuntaiEquipment(luntaiEquipment));
    }

    /**
     * 删除轮胎器材
     */
    @PreAuthorize("@ss.hasPermi('system:equipment:remove')")
    @Log(title = "轮胎器材", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiEquipmentService.deleteLuntaiEquipmentByIds(ids));
    }
}
